package com.qdlc.p2p.manage.action.additional;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;

import com.opensymphony.xwork2.ModelDriven;
import com.qdlc.p2p.biz.service.AdditionalMovieTicketService;
import com.qdlc.p2p.biz.web.action.BaseAction;
import com.qdlc.p2p.dal.common.model.jpa.PageDataList;
import com.qdlc.p2p.dal.model.AdditionalMovieTicketModel;

/**
 * Created on 2015/01/22.
 */
public class ManageMovieTicketExchangeAction extends BaseAction<AdditionalMovieTicketModel> implements ModelDriven<AdditionalMovieTicketModel> {
    @Resource
    private AdditionalMovieTicketService additionalMovieTicketService;

    private AdditionalMovieTicketModel model = new AdditionalMovieTicketModel();

    public AdditionalMovieTicketModel getModel() {
        return model;
    }

    private Map<String, Object> data;

    /**
     * -------------------用户兑换码兑换详情---------------------------
     *  进入页面
     * @return
     */
    @Action("/modules/additional/movieTicket/userMovieTicketExchangeManager")
    public String exchangeListPage() {
        return "userMovieTicketExchangeManager";
    }

    @Action("/modules/additional/movieTicket/exchangeList")
    public void exchangeList() throws IOException {
        data = new HashMap<String, Object>();
        PageDataList<AdditionalMovieTicketModel> pageDataList = additionalMovieTicketService.list(model);
        if (pageDataList == null) return;
        data.put("total", pageDataList.getPage().getTotal());
        data.put("rows", pageDataList.getList());
        printJson(getStringOfJpaObj(data));
    }

}
